<?
 session_start();
 require("connect.php"); 
 $chon = $_REQUEST["option"];
	if ($_REQUEST["option"]==Xoa)
	mysql_query("delete from sodaubai where masdb='{$_REQUEST["masdb"]}'");	
?>
<html><!-- InstanceBegin template="/Templates/sodaubaitemplate.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<!-- InstanceBeginEditable name="doctitle" -->
<title>Untitled Document</title>
<!-- InstanceEndEditable -->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script language="Javascript" src="scripts/innovaeditor.js"></script>
<link rel="stylesheet" type="text/css" href="css/engine.css" />
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
<script language="javascript" type="text/javascript" src="js/datetimepicker.js">
</script>
</head>
<body>
<table align="center" width="938" cellpadding="0" cellspacing="0" border="0">
	<tr><td colspan="2" height="26" bgcolor="#CCCCCC">
	<? $malop=$_REQUEST["mal"];
	$resu99=mysql_query("select * from lop where mal='{$malop}'");
		$row99=mysql_fetch_array($resu99);
	?>	
	<!--Menu 1-->
	<div id="tool">

	<a href="index.php">Trang chủ trường</a>
		 | 
		  <a href="hotrohoctap.php">Hỗ trợ học tập</a>
		  |		
		<a href="lienhe.php">Liên hệ</a>
	</div>
	<!--het menu 1-->
	</td></tr>
	<tr><td colspan="2" height="34" bgcolor="#CCCCCC">
	<div id="menuwrapper">
		<ul id="p7menubar">
			 <li><a class="trigger" href="lopcuatoi.php?mal=<? echo $malop;?>" target="_self">Trang chủ <? echo $row99["tenl"];?></a></li>										  	
		  <li class="linemenus"></li>					 
		  <li>
		  <?
		  	if ($_SESSION["login"]!=true){
		  ?>		  
		  <a class="trigger" href="login.php" target="_self">Trang cá nhân</a>
		  <? } else {
		  		if($_SESSION["quyen"]==0) {
		  ?>	
		   			<a class="trigger" href="admin/index.php" target="_self">Trang cá nhân</a>
		  		<? } else if($_SESSION["quyen"]==1) {?>
					<a class="trigger" href="giaovien.php?magv=<? echo $_SESSION["username"];?>" target="_self">Trang cá nhân</a>
				<? } else if($_SESSION["quyen"]==2) {?>
					<a class="trigger" href="trangphuhuynh.php?maph=<? echo $_SESSION["username"];?>&mal=<? echo $malop;?>" target="_self">Trang cá nhân</a>
				<? } else if(($_SESSION["quyen"]==3) || ($_SESSION["quyen"]==4)) {?>
					<a class="trigger" href="tranghocsinh.php?mahs=<? echo $_SESSION["username"];?>&mal=<? echo $malop;?>" target="_self">Trang cá nhân</a>
				<? }?>
		  		
		  <? }?>
		  <!--bat dau phan dang nhap-->
		  <?
				if ($_SESSION["login"]!=true){
			?>
			 <li class="linemenus"></li>					 
		  	 <li><a class="trigger" href="login.php" target="_self">Đăng nhập</a>			
			<? }else{?>
			 <li class="linemenus"></li>					 
		  	 <li><a class="trigger" href="logout.php" target="_self">Thoát</a>			
			 <li class="linemenus"></li>
			 <li><a class="trigger">
			 	<?
		$nguoidung=$_SESSION["username"];
		if($_SESSION["quyen"]==0){
		$resu23=mysql_query("select * from admin where maadmin='{$nguoidung}'");
		$row23=mysql_fetch_array($resu23);
		?>
			<font color="#FFFFFF">			 
			<? echo "Xin chào : ".$row23["hotendem"]."&nbsp;".$row23["ten"]; ?>
			</font>
		<? }else if($_SESSION["quyen"]==1){
			$resu23=mysql_query("select * from giaovien where magv='{$nguoidung}'");
			$row23=mysql_fetch_array($resu23);
		?>
			<font color="#FFFFFF">			 
			<? echo "Xin chào : ".$row23["hotendem"]."&nbsp;".$row23["ten"]; ?>
			</font>
		<? }else if($_SESSION["quyen"]==2){
			$resu23=mysql_query("select * from phuhuynh where maph='{$nguoidung}'");
			$row23=mysql_fetch_array($resu23);
		?>
			<font color="#FFFFFF">			 
			<? echo "Xin chào : ".$row23["tenph"]; ?>
			</font>
		<? }else if(($_SESSION["quyen"]==3)||($_SESSION["quyen"]==4)){
				$resu23=mysql_query("select * from hocsinh where mahs='{$nguoidung}'");
				$row23=mysql_fetch_array($resu23);
		?>
			<font color="#FFFFFF">			 
			<? echo "Xin chào : ".$row23["hotendem"]."&nbsp;".$row23["ten"]; ?>
			</font>
		<? }
	}?>
		  <!--het-->		 
		</ul>
	</div>
	</td></tr>
	<tr>
		<td width="160px" height="800" valign="top">
		<!--menu trai-->		
		<table align="center" width="100%" border="1" cellpadding="0" cellspacing="0">
		<tr><td valign="middle" height="30">
			<a href="sodaubai.php?mal=<? echo $malop;?>"><img src="anh/sodaubai.png" height="16" width="16" border="0">&nbsp;&nbsp;</a><a href="sodaubai.php?mal=<? echo $malop;?>">Sổ đầu bài</a>
		</td></tr>
		<tr><td valign="middle" height="30">
			<a href="danhsachhocsinh.php?mal=<? echo $malop;?>"><img src="anh/user.png" height="16" width="16" border="0">&nbsp;&nbsp;</a><a href="danhsachhocsinh.php?mal=<? echo $malop;?>">Danh sách học sinh</a>
		</td></tr>
		<tr><td valign="middle" height="30">
			<a href="thuvienanhlop.php?mal=<? echo $malop;?>.php"><img src="anh/album.png" height="16" width="16" border="0">&nbsp;&nbsp;</a><a href="thuvienanhlop.php?mal=<? echo $malop;?>">Thư viện ảnh</a>
		</td></tr>
		<tr><td valign="middle" height="30">
			<a href="lopcuatoi_baiviet.php?mal=<? echo $malop;?>"><img src="anh/baiviet.png" height="16" width="16" border="0">&nbsp;&nbsp;</a><a href="lopcuatoi_baiviet.php?mal=<? echo $malop;?>">Bài viết</a>
		</td></tr>
		<tr><td valign="middle" height="30">
			<a href="thoikhoabieu.php?mal=<? echo $malop;?>"><img src="anh/thoikhoabieu.png" height="16" width="16" border="0">&nbsp;&nbsp;</a><a href="thoikhoabieu.php?mal=<? echo $malop;?>">Thời khóa biểu</a>
		</td></tr>
		<tr><td valign="middle" height="30">
			<a href="thongbaolop.php?mal=<? echo $malop;?>"><img src="anh/thongbao.png" height="16" width="16" border="0">&nbsp;&nbsp;</a><a href="thongbaolop.php?mal=<? echo $malop;?>">Thông báo</a>
		</td></tr>
		<tr><td valign="middle" height="30">
			<a href="tailieulop.php?mal=<? echo $malop;?>""><img src="anh/tailieu.png" height="16" width="16" border="0">&nbsp;&nbsp;</a><a href="tailieulop.php?mal=<? echo $malop;?>">Tài liệu Upload</a>
		</td></tr>
		<tr><td valign="middle" height="30">
			<a href="xemdiemlop.php?mal=<? echo $malop;?>""><img src="anh/xemdiem.png" height="16" width="16" border="0">&nbsp;&nbsp;</a><a href="xemdiemlop.php?mal=<? echo $malop;?>">Xem điểm</a>
		</td></tr>			
		</table>
		<!-- het menu trai-->
	</td>
		
    <td align="center" valign="top"><!-- InstanceBeginEditable name="EditRegion3" -->	
	<?
		$mal=$_REQUEST["mal"];				
	?>
	<!--Begin -->
		<table align="right" width="99%" cellpadding="2" cellspacing="2" border="0">
		<tr>
			<td align="center">
			<!--Begin tieu de-->
				<div class="sodaubai">
					<div class="gift_quatang_topblog">
						<p class="gift_quatang_fl_left"><img src="anh/space.gif"></p>
						<p class="gift_quatang_fl_right"><img src="anh/space.gif"></p>
					</div>
					<div class="noidungsodaubai">
						<h1></h1>
							<font size="+2" color="#003366">
								Sổ đầu bài lớp <? 
								$result3=mysql_query("select * from lop where mal='{$mal}'");
								$r3=mysql_fetch_array($result3);
								echo $r3["tenl"];
								?>	
							</font>																			 
						<div class="gift_quatang_mView">
							<span style="float:left; width:120px;">
							<!--Neu la giao vien thi hien link-->
								<?
								if($_SESSION["login"]==true)
								{
								if($_SESSION["quyen"]==1)
								{
								?>									
									<a href="themsodaubai.php?mal=<? echo $mal;?>">
									<img src="anh/them.png" height="13" width="13" border="0">&nbsp;									
									<b>Thêm nhận xét</b>
									</a> 
								<? }
								}
								?>		
							</span>
							<span style=" float: right;">
												<a href="xemsodaubai.php?mal=<? echo $mal;?>">
									<img src="anh/chitiet.png" height="13" width="13" border="0">&nbsp;Xem theo ngày
								</a>			
							</span>
						</div>
					</div>
					<div class="gift_quatang_btmblog">
						<p class="gift_quatang_bl_left"><img src="anh/space.gif"></p>
						<p class="gift_quatang_bl_right"><img src="anh/space.gif"></p>
					</div>			
				</div>
			<!--End tieu de-->
			<div class="sodaubai">
					<div class="gift_quatang_topblog">
						<p class="gift_quatang_fl_left"><img src="anh/space.gif"></p>
						<p class="gift_quatang_fl_right"><img src="anh/space.gif"></p>
					</div>
					<div class="noidungsodaubai">
					<?					
					$date=$_POST["demol1"];
					$sqldate = strtotime($date);
					$ngay = date('Y-m-d', $sqldate);
					$result1=mysql_query("select * from sodaubai where mal='{$mal}' and ngay='{$ngay}' order by tiethoc");
					?>
						<h1 align="left">										
			<!--Begin so dau bai theo ngay-->
							<font color="#CC3333">&nbsp;Ngày <? echo $ngay; ?></font>												
							</h1>
						
						<table align="center" width="745px" cellpadding="4" cellspacing="0" border="0">
						<?
						if(mysql_num_rows($result1)<=0){
						?>
							<center>Không có thông tin sổ đầu bài ngày <? echo $ngay;?></center>
						<?
						}else {
						?>
						<tr>
							<th align="center">Tiết</th>	
							<th align="center">Môn học</th>
							<th align="center">Sĩ số</th>												
							<th align="center">Xếp loại</th>
							<th align="center">Giáo viên</th>							
							<th align="center">Chi tiết</th>							
														
						</tr>						
						<?							
							while($r1=mysql_fetch_array($result1)){
						?>
						<tr>
							<td align="center">
								<a href="sodaubaitheotiet.php?masdb=<? echo $r1["masdb"];?>&mal=<? echo $r1["mal"];?>" title="Xem chi tiết">
									<? echo $r1["tiethoc"];?>
								</a>
							</td>
							<td align="center">
								<? 
									$result4=mysql_query("select * from monhoc where mamh='{$r1["mamh"]}'");
									$r4=mysql_fetch_array($result4);
									echo $r4["tenmh"];
								?>								
							</td>
							<td align="center"><?
								$result6=mysql_query("select * from hocsinh where mal='{$r1["mal"]}'");
								$n=mysql_num_rows($result6);
								$n1=$n-$r1["hsvang"];
								echo $n1;echo " / ";echo $n;
							?></td>						
							<td align="center">
							<?
								if($r1["xeploai"]==1) {
							 		echo "Tốt";
									};
								if($r1["xeploai"]==2) {
							 		echo "Khá";
									};
								if($r1["xeploai"]==3) {
							 		echo "Trung bình";
									};
								if($r1["xeploai"]==4) {
							 		echo "Yếu";
									};
							?>
							</td>
							<td align="center"><?
								$result2=mysql_query("select * from giaovien where magv='{$r1["magv"]}'");
								$r2=mysql_fetch_array($result2);
								echo $r2["hotendem"];
								echo "&nbsp;";
								echo $r2["ten"];
							
							 ?></td>
							<td align="center"><a href="sodaubaitheotiet.php?masdb=<? echo $r1["masdb"];?>&mal=<? echo $r1["mal"];?>" title="Xem chi tiết">
								<img src="anh/chitiet.png" height="14" width="14" border="0"></a>							
							<? if(($_SESSION["quyen"]==1)&&($_SESSION["username"])==$r1["magv"])
							{
							?>							
								<a href="suasodaubai.php?masdb=<? echo $r1["masdb"];?>&mal=<? echo $mal;?>" title="Sửa">
									<img src="anh/sua.png" height="14" width="14" border="0">
								</a>														
								<a href="?masdb=<? echo $r1["masdb"];?>&option=Xoa&mal=<? echo $mal;?>" title="Xóa nhận xét" onClick="return confirm('Bạn có chắc muốn xóa không ?');">									
								<img src="anh/xoa.png" height="14" width="14" border="0">
								</a>
							
							<? } ?>	
							</td>													
						</tr>					
						<? }	}?>
						</table>												
				<div class="sodaubai_bottom">
							<span style="float:left; width:70px;">
								<strong>
								<? 
									for($i = 1; $i <=$num_page; $i++)
									if ($i==$page)  echo "&nbsp;&nbsp;".$i."&nbsp;";
									else echo "&nbsp;<a href=?page={$i}>&nbsp;&nbsp;{$i}</a>&nbsp;";
								?>
								</strong>
							</span>
							<span style=" float: right;">
								
							</span>
						</div>
					</div>
					<div class="gift_quatang_btmblog">
						<p class="gift_quatang_bl_left"><img src="anh/space.gif"></p>
						<p class="gift_quatang_bl_right"><img src="anh/space.gif"></p>
					</div>			
				</div>
			<!--End so dau bai theo ngay-->
			</td>
		</tr>
		</table>
	<!--End-->	
	<!-- InstanceEndEditable --></td>
	
	</tr>
	<tr><td colspan="2" align="center" valign="middle" bgcolor="#999999" height="100">Phạm Đức Đóa - Khoa CNTT - Đại học Xây Dựng</td></tr>
</table>
</body>
<!-- InstanceEnd --></html>
